<template>
  <iframe :src="url" class="pd-container"></iframe>
</template>

<script>
import { getAction } from '@api/manage'
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
import { showZwtNav } from '@/utils/showNav.js'

export default {
  name: 'GdwyyAppPd',

  data() {
    return {
      sessionId: '',
    }
  },

  created() {
    showZwtNav(this.$route.meta.title)
    this.checkAuthH5()
  },

  computed: {
    url() {
      const pageType = this.$route.path.split('/')[this.$route.path.split('/').length-1] 
      if (process.env.NODE_ENV == 'production') {
        return `https://sp.10010.com:90/nrvp_sp?sessionId=${this.sessionId}&path=${pageType}`
      }
      return `https://sp.10010.com:90/nrvp_sp?sessionId=${this.sessionId}&path=${pageType}`
      return `http://10.242.37.15:9996/nrvp_sp?sessionId=${this.sessionId}&path=${pageType}`
    },
    
  },

  methods: {
    async checkAuthH5() {
      const userInfo = Vue.ls.get(USER_INFO) || {}
      const { success, code, result } = await getAction(`/sys/checkAuthH5?phone=${userInfo.phone}`)
      success && code === 200 && (this.sessionId = result.phone || 'EDBvvPc/k1gVUWM0yrLcPg==')
    },
  },
}
</script>

<style lang="less" scoped>
.pd-container {
  width: 100%;
  height: 100vh;
  overflow: auto;
}
</style>